package Singleton;

/**
 * Created by wangyg 
 * on 2017/6/13 20:13
 */
public class StaticInnerClassSingleton {

	private static class inner {
		private static final StaticInnerClassSingleton instance = new StaticInnerClassSingleton();

	}

	private StaticInnerClassSingleton() {
	}

	public static StaticInnerClassSingleton getInstance() throws InterruptedException {
		Thread.sleep(100);
		return inner.instance;
	}

	public static void main(String[] args) throws InterruptedException {
		for (int i = 0; i < 10; i++) {
			new Thread() {
				public void run() {

					try {
						System.out.println(
								Thread.currentThread().getName() + ":" + StaticInnerClassSingleton.getInstance().hashCode());
					} catch (InterruptedException e) {
						e.printStackTrace();
					}

				}
			}.start();
			//			Thread.sleep(600);
		}

	}
}

